﻿using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using Duo1JHttpServer.Framework.Analyzer;
using Duo1JHttpServer.Framework.Enum;
using Duo1JHttpServer.Framework.Interface;
using Duo1JHttpServer.Framework.Model;

namespace Duo1JHttpServer.Framework.Config
{
    public class GlobalDefine
    {
        #region Prefix

        /// <summary>
        /// 静态文件路径前缀
        /// </summary>
        public const string StaticFilePathPrefix = "\\Static\\";

        /// <summary>
        /// 视图文件路径前缀
        /// </summary>
        public const string ViewFilePathPrefix = "\\Views\\";

        #endregion

        #region FileName

        /// <summary>
        /// 主配置文件名
        /// </summary>
        public const string MainConfigName = "Server.properties";

        #endregion

        #region Regex

        /// <summary>
        /// Xml文件名匹配
        /// </summary>
        public static readonly Regex XmlRegex = new Regex(".+\\.xml");

        /// <summary>
        /// 解析器模型列表
        /// </summary>
        public static readonly List<AnalyzerModel> AnalyzerModels = new List<AnalyzerModel>()
        {
            new AnalyzerModel(ConfigType.Mapper, new Regex(".+\\.mapper\\.xml"), new MapperAnalyzer()),
            new AnalyzerModel(ConfigType.Filter, new Regex(".+\\.filter\\.xml"), new FilterAnalyzer())
        };

        #endregion

        #region Path

        /// <summary>
        /// 程序根路径
        /// </summary>
        //public static readonly string Root = Directory.GetCurrentDirectory();
        public static readonly string Root = "D:\\Visual Studio Projects\\C#\\WebServer\\WebServer\\";

        /// <summary>
        /// Static文件夹路径
        /// </summary>
        public static readonly string StaticRoot = $"{Root}{StaticFilePathPrefix}";

        /// <summary>
        /// 视图文件夹路径
        /// </summary>
        public static readonly string ViewRoot = $"{Root}{StaticFilePathPrefix}{ViewFilePathPrefix}";

        /// <summary>
        /// 主配置文件路径
        /// </summary>
        public static readonly string MainConfigPath = $"{StaticRoot}{MainConfigName}";

        #endregion
    }
}